from machine import Pin
import utime
import network

# 创建WLAN对象
wlan = network.WLAN(network.STA_IF)
wlan.active(True)

# SSID信息
ssid = "Redmi K60 Ultra"
pwd = "24361234"

# LED提示灯
led = Pin(16, Pin.OUT, value=0)


if __name__ == "__main__":
    # 建立wifi连接
    start_time = utime.time()
    
    if not wlan.isconnected():
        print("正在连接路由器...")
        wlan.connect(ssid, pwd)
        
        while True:
            led.value(1)
            utime.sleep_ms(250)
            led.value(0)
            utime.sleep_ms(250)
            if wlan.isconnected():
                print("WLAN config: ", wlan.ifconfig())
                break
            elif utime.time() - start_time > 15:
                print("连接超时...")
                break
    else:
        led.value(0)
        print("WLAN config: ", wlan.ifconfig())
    
    
    while True:
        pass
    
    
    
    
    

